package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;

import com.itheima.pojo.IdGroup;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {

    @Select("select * from t_checkgroup limit #{begin},#{pageSize}")
    List<CheckGroup> findByPage(@Param("begin") int begin, @Param("pageSize") Integer pageSize);

    @Select("select count(1) from t_checkgroup")
    Long count();

    @Select("select * from t_checkgroup_checkitem where checkgroup_id=#{checkgroup_id}")
    List<IdGroup> selectGroupId(@Param("checkgroup_id") Integer id);

    @Select("select * from t_checkitem where id=#{id}")
    CheckItem selectItemId(@Param("id") Integer id);

    @Select("select * from t_checkgroup where code=#{code}")
    CheckGroup selectByCode(@Param("code")String code);

    @Insert("insert into t_checkgroup values (null,#{code},#{name},#{helpCode},#{sex},#{remark},#{attention})")
    void insertGroup(CheckGroup checkGroup);
}
